package com.mysiteforme.admin.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.mysiteforme.admin.controller.ElectricityMessagePushController;
import com.mysiteforme.admin.entity.*;
import com.mysiteforme.admin.dao.ElectricityMessagePushDao;
import com.mysiteforme.admin.entity.publish.ElectricityOrder;
import com.mysiteforme.admin.entity.publish.ElectricitySupply;
import com.mysiteforme.admin.realm.AuthRealm;
import com.mysiteforme.admin.service.*;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.mysiteforme.admin.util.Constants;
import com.mysiteforme.admin.util.MessageConstants;
import com.mysiteforme.admin.util.Response;
import com.mysiteforme.admin.util.SendMessagePush;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * <p>
 * 消息推送表 服务实现类
 * </p>
 *
 * @author wangl
 * @since 2019-10-22
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ElectricityMessagePushServiceImpl extends ServiceImpl<ElectricityMessagePushDao, ElectricityMessagePush> implements ElectricityMessagePushService {
    private static final Logger LOGGER = LoggerFactory.getLogger(ElectricityMessagePushController.class);
    @Autowired
    private ElectricityUserService electricityUserService;
    @Autowired
    private UserService userService;
    @Autowired
    private ElectricityMessagePushService electricityMessagePushService;
    @Autowired
    private SendMessagePush sendMessagePush;
    @Autowired
    private ElectricityMessagePushDescService electricityMessagePushDescService;
    @Autowired
    private ElectricityPushFreemakerService electricityPushFreemakerService;
    @Autowired
    private ElectricityPushFreemakerDescService electricityPushFreemakerDescService;


    @Override
    public void insertSupplyMessage(ElectricitySupply electricitySupply, String id) {
        ElectricityUser user = electricityUserService.selectById(id);
        AuthRealm.ShiroUser shiroUser = (AuthRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
        User loginUser = userService.selectById(shiroUser.getId());
        if (StringUtils.isEmpty(user.getOpenid())) {
            ElectricityMessagePush messagePush = new ElectricityMessagePush();
            messagePush.setType("0");
            messagePush.setMessageType("1");
            messagePush.setIsWechat("2");
            messagePush.setPushStatus("1");
            messagePush.setPushDate(new Date());
            if (electricitySupply.getAuditingStatu().equals("1")) {
                messagePush.setTitle("审核通过推送消息");
                messagePush.setContent("审核已通过，您可以发布消息咯！");
            } else if (electricitySupply.getAuditingStatu().equals("2")) {
                messagePush.setTitle("审核拒绝推送消息");
                messagePush.setContent("审核已拒绝，如有疑问请联系管理员");
            }
            messagePush.setType("0");
            messagePush.setUserId(user.getId().toString());
            messagePush.setCreateDate(new Date());
            messagePush.setCreateId(loginUser.getId());
            messagePush.setUpdateDate(new Date());
            messagePush.setUpdateId(loginUser.getId());
            electricityMessagePushService.insert(messagePush);
        } else {
            JSONObject jsonObject = MessageConstants.sendSupply(electricitySupply);
            try {
                boolean b = true;
                int i = 0;
                do {
                    LOGGER.info("------->>开始发送卖方通知组装消息为：" + jsonObject.toString() + "<<-------");
                    Response<?> rs = null;
                    if (electricitySupply.getAuditingStatu().equals("1")) {
                        rs = sendMessagePush.sendMessagePush(user.getOpenid(), MessageConstants.messageId_supply,
                                null, jsonObject, Constants.MEESSAGE_PUSH_COLOUR);
                    } else if (electricitySupply.getAuditingStatu().equals("2")) {
                        rs = sendMessagePush.sendMessagePush(user.getOpenid(), MessageConstants.messageId_refuse,
                                null, jsonObject, Constants.MEESSAGE_PUSH_COLOUR);
                    }
                    //如果返回状态码为40001则重新发送
                    b = getBoolean(b, rs, "通知卖家", i);
                    i++;
                } while (b);

                ElectricityMessagePush messagePush = new ElectricityMessagePush();
                messagePush.setUserId(user.getId().toString());
                messagePush.setMessageType("1");
                messagePush.setIsWechat("1");
                if (electricitySupply.getAuditingStatu().equals("1")) {
                    messagePush.setFreemakerId(MessageConstants.messageId_supply);
                } else if (electricitySupply.getAuditingStatu().equals("2")) {
                    messagePush.setFreemakerId(MessageConstants.messageId_refuse);
                }
                messagePush.setPushStatus("1");
                messagePush.setPushDate(new Date());
                messagePush.setCreateDate(new Date());
                messagePush.setCreateId(loginUser.getId());
                messagePush.setUpdateDate(new Date());
                messagePush.setUpdateId(loginUser.getId());
                messagePush.setType("0");
                electricityMessagePushService.insert(messagePush);

                if (jsonObject.size() > 0) {
                    Set<String> set = jsonObject.keySet();
                    for (String key : set) {
                        EntityWrapper<ElectricityPushFreemakerDesc> descEntityWrapper = new EntityWrapper<>();
                        EntityWrapper<ElectricityPushFreemaker> freemakerEntityWrapper = new EntityWrapper<>();
                        if (electricitySupply.getAuditingStatu().equals("1")) {
                            freemakerEntityWrapper.eq("del_flag", 0);
                            freemakerEntityWrapper.eq("freemaker_id", MessageConstants.messageId_supply);
                        } else if (electricitySupply.getAuditingStatu().equals("2")) {
                            freemakerEntityWrapper.eq("del_flag", 0);
                            freemakerEntityWrapper.eq("freemaker_id", MessageConstants.messageId_refuse);
                        }
                        ElectricityPushFreemaker pushFreemaker = electricityPushFreemakerService.selectOne(freemakerEntityWrapper);
                        descEntityWrapper.eq("freemaker_id", pushFreemaker.getId().toString());
                        List<ElectricityPushFreemakerDesc> pushFreemakerDescList = electricityPushFreemakerDescService.selectList(descEntityWrapper);


                        ElectricityMessagePushDesc messagePushDesc = new ElectricityMessagePushDesc();
                        messagePushDesc.setPushId(messagePush.getId().toString());
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        for (ElectricityPushFreemakerDesc pushFreemakerDesc : pushFreemakerDescList) {
                            if (key.equals(pushFreemakerDesc.getWxCode())) {
                                messagePushDesc.setWxCode(pushFreemakerDesc.getWxDesc());
                                break;
                            }
                        }
                        if (electricitySupply.getAuditingStatu().equals("1")) {
                            if (key.equals("first")) {
                                messagePushDesc.setWxDesc(MessageConstants.check_pass);
                            }
                            if (key.equals("keyword1")) {
                                messagePushDesc.setWxDesc("供需发布审核");
                            }
                            if (key.equals("keyword2")) {
                                messagePushDesc.setWxDesc(formatter.format(electricitySupply.getPublishTime()));
                            }
                            if (key.equals("keyword3")) {
                                messagePushDesc.setWxDesc(MessageConstants.check_pass);
                            }
                            if (key.equals("remark")) {
                                messagePushDesc.setWxDesc(MessageConstants.check_remark);
                            }
                        } else if (electricitySupply.getAuditingStatu().equals("2")) {
                            if (key.equals("first")) {
                                messagePushDesc.setWxDesc("审核驳回");
                            }
                            if (key.equals("keyword1")) {
                                messagePushDesc.setWxDesc(formatter.format(electricitySupply.getUpdateDate()));
                            }
                            if (key.equals("keyword2")) {
                                messagePushDesc.setWxDesc("供需发布审核");
                            }
                            if (key.equals("keyword3")) {
                                messagePushDesc.setWxDesc(null);
                            }
                            if (key.equals("remark")) {
                                messagePushDesc.setWxDesc("如有疑问请联系管理员");
                            }
                        }


                        messagePushDesc.setCreateDate(new Date());
                        messagePushDesc.setCreateId(loginUser.getId());
                        messagePushDesc.setUpdateDate(new Date());
                        messagePushDesc.setUpdateId(loginUser.getId());
                        messagePushDesc.setMessageType(messagePush.getMessageType());
                        electricityMessagePushDescService.insert(messagePushDesc);
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void insertMessage(ElectricityCompany company, Long id) {
        ElectricityUser user = electricityUserService.selectById(id);
        AuthRealm.ShiroUser shiroUser = (AuthRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
        User loginUser = userService.selectById(shiroUser.getId());
        if (StringUtils.isEmpty(user.getOpenid())) {
            ElectricityMessagePush messagePush = new ElectricityMessagePush();
            messagePush.setType("0");
            messagePush.setMessageType("1");
            messagePush.setIsWechat("2");
            messagePush.setPushStatus("1");
            messagePush.setPushDate(new Date());
            if (company.getIsCheck().equals("1")) {
                messagePush.setTitle("审核通过推送消息");
                messagePush.setContent("审核已通过，您可以发布消息咯！");
            } else if (company.getIsCheck().equals("2")) {
                messagePush.setTitle("审核拒绝推送消息");
                messagePush.setContent(company.getRefuseMsg());
            }
            messagePush.setType("0");
            messagePush.setUserId(user.getId().toString());
            messagePush.setCreateDate(new Date());
            messagePush.setCreateId(loginUser.getId());
            messagePush.setUpdateDate(new Date());
            messagePush.setUpdateId(loginUser.getId());
            electricityMessagePushService.insert(messagePush);
        } else {
            JSONObject jsonObject = MessageConstants.sendUser(company);
            try {
                boolean b = true;
                int i = 0;
                do {
                    LOGGER.info("------->>开始发送卖方通知组装消息为：" + jsonObject.toString() + "<<-------");
                    Response<?> rs = null;
                    if (company.getIsCheck().equals("1")) {
                        rs = sendMessagePush.sendMessagePush(user.getOpenid(), MessageConstants.messageId_pass,
                                null, jsonObject, Constants.MEESSAGE_PUSH_COLOUR);
                    } else if (company.getIsCheck().equals("2")) {
                        rs = sendMessagePush.sendMessagePush(user.getOpenid(), MessageConstants.messageId_fail,
                                null, jsonObject, Constants.MEESSAGE_PUSH_COLOUR);
                    }
                    //如果返回状态码为40001则重新发送
                    b = getBoolean(b, rs, "通知用户", i);
                    i++;
                } while (b);

                ElectricityMessagePush messagePush = new ElectricityMessagePush();
                messagePush.setUserId(user.getId().toString());
                messagePush.setMessageType("1");
                messagePush.setIsWechat("1");
                if (company.getIsCheck().equals("1")) {
                    messagePush.setFreemakerId(MessageConstants.messageId_pass);
                } else if (company.getIsCheck().equals("2")) {
                    messagePush.setFreemakerId(MessageConstants.messageId_fail);
                }
                messagePush.setPushStatus("1");
                messagePush.setPushDate(new Date());
                messagePush.setCreateDate(new Date());
                messagePush.setCreateId(loginUser.getId());
                messagePush.setUpdateDate(new Date());
                messagePush.setUpdateId(loginUser.getId());
                messagePush.setType("0");
                electricityMessagePushService.insert(messagePush);

                if (jsonObject.size() > 0) {
                    Set<String> set = jsonObject.keySet();
                    for (String key : set) {
                        EntityWrapper<ElectricityPushFreemakerDesc> descEntityWrapper = new EntityWrapper<>();
                        List<ElectricityPushFreemakerDesc> pushFreemakerDescList = null;
                        EntityWrapper<ElectricityPushFreemaker> freemakerEntityWrapper = new EntityWrapper<>();
                        if (company.getIsCheck().equals("1")) {
                            freemakerEntityWrapper.eq("del_flag", 0);
                            freemakerEntityWrapper.eq("freemaker_id", MessageConstants.messageId_pass);
                        } else if (company.getIsCheck().equals("2")) {
                            freemakerEntityWrapper.eq("del_flag", 0);
                            freemakerEntityWrapper.eq("freemaker_id", MessageConstants.messageId_fail);
                        }
                        ElectricityPushFreemaker pushFreemaker = electricityPushFreemakerService.selectOne(freemakerEntityWrapper);
                        descEntityWrapper.eq("freemaker_id", pushFreemaker.getId().toString());
                        pushFreemakerDescList = electricityPushFreemakerDescService.selectList(descEntityWrapper);

                        ElectricityMessagePushDesc messagePushDesc = new ElectricityMessagePushDesc();
                        messagePushDesc.setPushId(messagePush.getId().toString());
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                        for (ElectricityPushFreemakerDesc pushFreemakerDesc : pushFreemakerDescList) {
                            if (key.equals(pushFreemakerDesc.getWxCode())) {
                                messagePushDesc.setWxCode(pushFreemakerDesc.getWxDesc());
                                break;
                            }
                        }
                        if (key.equals("keyword1")) {
                            messagePushDesc.setWxDesc(formatter.format(company.getUpdateDate()));
                        }
                        if (company.getIsCheck().equals("1")) {
                            if (key.equals("first")) {
                                messagePushDesc.setWxDesc("您的信息已通过审核");
                            }
                            if (key.equals("keyword2")) {
                                messagePushDesc.setWxDesc(company.getCompanyName());
                            }
                        } else if (company.getIsCheck().equals("2")) {
                            if (key.equals("first")) {
                                messagePushDesc.setWxDesc("您的信息未通过审核");
                            }
                            if (key.equals("keyword2")) {
                                messagePushDesc.setWxDesc("企业信息审核");
                            }
                            if (key.equals("keyword3")) {
                                messagePushDesc.setWxDesc(company.getRefuseMsg());
                            }
                        }
                        if (key.equals("remark")) {
                            messagePushDesc.setWxDesc("如有疑问请联系管理员！");
                        }

                        messagePushDesc.setCreateDate(new Date());
                        messagePushDesc.setCreateId(loginUser.getId());
                        messagePushDesc.setUpdateDate(new Date());
                        messagePushDesc.setUpdateId(loginUser.getId());
                        messagePushDesc.setMessageType(messagePush.getMessageType());
                        electricityMessagePushDescService.insert(messagePushDesc);
                    }
                }


            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void send(ElectricityOrder order) {
        //并行发送公众消息
        ExecutorService service = Executors.newCachedThreadPool();
        service.execute(() -> sendSellMessage(order));
        service.execute(() -> sendBuyMessage(order));
        service.shutdown();
    }

    public void sendBuyMessage(ElectricityOrder order) {
        ElectricityUser user = electricityUserService.selectById(order.getBuyId());
        AuthRealm.ShiroUser shiroUser = (AuthRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
        User loginUser = userService.selectById(shiroUser.getId());
        if (user != null) {
            String openid = user.getOpenid();
            if (!StringUtils.isEmpty(openid)) {
                String user_type = "1";
                JSONObject jsonObject = MessageConstants.sendMessage(order,user_type);
                try {
                    boolean b = true;
                    int i = 0;
                    do {
                        LOGGER.info("------->>开始发送卖方通知组装消息为：" + jsonObject.toString() + "<<-------");
                        Response<?> rs = sendMessagePush.sendMessagePush(openid, MessageConstants.message_id,
                                MessageConstants.get_url, jsonObject, Constants.MEESSAGE_PUSH_COLOUR);
                        //如果返回状态码为40001则重新发送
                        b = getBoolean(b, rs, "通知卖家", i);
                        i++;
                    } while (b);

                    ElectricityMessagePush messagePush = new ElectricityMessagePush();
                    messagePush.setUserId(user.getId().toString());
                    messagePush.setMessageType("2");
                    messagePush.setIsWechat("1");
                    messagePush.setFreemakerId(MessageConstants.message_id);
                    messagePush.setPushStatus("1");
                    messagePush.setPushDate(new Date());
                    messagePush.setCreateDate(new Date());
                    messagePush.setCreateUser(loginUser);
                    messagePush.setUpdateDate(new Date());
                    messagePush.setUpdateUser(loginUser);
                    messagePush.setType("1");
                    messagePush.setDelFlag(false);
                    electricityMessagePushService.insert(messagePush);

                    if (jsonObject.size() > 0) {
                        Set<String> set = jsonObject.keySet();
                        for (String key : set) {
                            ElectricityMessagePushDesc messagePushDesc = new ElectricityMessagePushDesc();
                            messagePushDesc.setPushId(messagePush.getId().toString());

                            EntityWrapper<ElectricityPushFreemaker> freemakerEntityWrapper = new EntityWrapper<>();
                            freemakerEntityWrapper.eq("del_flag", 0);
                            freemakerEntityWrapper.eq("freemaker_id", MessageConstants.message_id);
                            ElectricityPushFreemaker pushFreemaker = electricityPushFreemakerService.selectOne(freemakerEntityWrapper);

                            EntityWrapper<ElectricityPushFreemakerDesc> descEntityWrapper = new EntityWrapper<>();
                            descEntityWrapper.eq("del_flag", 0);
                            descEntityWrapper.eq("freemaker_id", pushFreemaker.getId().toString());
                            List<ElectricityPushFreemakerDesc> descList = electricityPushFreemakerDescService.selectList(descEntityWrapper);
                            for (ElectricityPushFreemakerDesc desc : descList) {
                                if (key.equals(desc.getWxCode())) {
                                    messagePushDesc.setWxCode(desc.getWxDesc());
                                    break;
                                }
                            }
                            if (key.equals("first")) {
                                messagePushDesc.setWxDesc(order.getSellCompany() +
                                        ",您好!您在【" + order.getBuyCompany() + "】的订单已经处理");
                            }
                            if (key.equals("keyword1")) {
                                messagePushDesc.setWxDesc(order.getTradeNo());
                            }
                            if (key.equals("keyword2")) {
                                if (order.getOrderStatu().equals("2")) {
                                    messagePushDesc.setWxDesc("已上报电力交易平台");
                                } else if (order.getOrderStatu().equals("3")) {
                                    messagePushDesc.setWxDesc("交易已完成");
                                }
                            }
                            if (key.equals("remark")) {
                                messagePushDesc.setWxDesc("点击“详情”,查看完整订单信息");
                            }

                            messagePushDesc.setCreateDate(new Date());
                            messagePushDesc.setCreateUser(loginUser);
                            messagePushDesc.setUpdateDate(new Date());
                            messagePushDesc.setUpdateUser(loginUser);
                            messagePushDesc.setDelFlag(false);
                            messagePushDesc.setMessageType(messagePush.getMessageType());
                            electricityMessagePushDescService.insert(messagePushDesc);
                        }
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                LOGGER.error("------->>通知用户失败：openId为null<<-------");
            }
        } else {
            LOGGER.error("------->>通知用户失败：openId为null<<-------");
        }
    }

    public void sendSellMessage(ElectricityOrder order) {
        ElectricityUser user = electricityUserService.selectById(order.getSellId());
        AuthRealm.ShiroUser shiroUser = (AuthRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
        User loginUser = userService.selectById(shiroUser.getId());
        if (user != null) {
            String openid = user.getOpenid();
            if (!StringUtils.isEmpty(openid)) {
                String user_type = "2";
                JSONObject jsonObject = MessageConstants.sendMessage(order,user_type);
                try {
                    boolean b = true;
                    int i = 0;
                    do {
                        LOGGER.info("------->>开始发送卖方通知组装消息为：" + jsonObject.toString() + "<<-------");
                        Response<?> rs = sendMessagePush.sendMessagePush(openid, MessageConstants.message_id,
                                MessageConstants.get_url, jsonObject, Constants.MEESSAGE_PUSH_COLOUR);
                        //如果返回状态码为40001则重新发送
                        b = getBoolean(b, rs, "通知卖家", i);
                        i++;
                    } while (b);

                    ElectricityMessagePush messagePush = new ElectricityMessagePush();
                    messagePush.setUserId(user.getId().toString());
                    messagePush.setMessageType("3");
                    messagePush.setIsWechat("1");
                    messagePush.setFreemakerId(MessageConstants.message_id);
                    messagePush.setPushStatus("1");
                    messagePush.setPushDate(new Date());
                    messagePush.setCreateDate(new Date());
                    messagePush.setCreateUser(loginUser);
                    messagePush.setUpdateDate(new Date());
                    messagePush.setUpdateUser(loginUser);
                    messagePush.setType("1");
                    messagePush.setDelFlag(false);
                    electricityMessagePushService.insert(messagePush);

                    if (jsonObject.size() > 0) {
                        Set<String> set = jsonObject.keySet();
                        for (String key : set) {
                            ElectricityMessagePushDesc messagePushDesc = new ElectricityMessagePushDesc();
                            messagePushDesc.setPushId(messagePush.getId().toString());

                            EntityWrapper<ElectricityPushFreemaker> freemakerEntityWrapper = new EntityWrapper<>();
                            freemakerEntityWrapper.eq("del_flag", 0);
                            freemakerEntityWrapper.eq("freemaker_id", MessageConstants.message_id);
                            ElectricityPushFreemaker pushFreemaker = electricityPushFreemakerService.selectOne(freemakerEntityWrapper);

                            EntityWrapper<ElectricityPushFreemakerDesc> descEntityWrapper = new EntityWrapper<>();
                            descEntityWrapper.eq("del_flag", 0);
                            descEntityWrapper.eq("freemaker_id", pushFreemaker.getId().toString());
                            List<ElectricityPushFreemakerDesc> descList = electricityPushFreemakerDescService.selectList(descEntityWrapper);
                            for (ElectricityPushFreemakerDesc desc : descList) {
                                if (key.equals(desc.getWxCode())) {
                                    messagePushDesc.setWxCode(desc.getWxDesc());
                                    break;
                                }
                            }
                            if (key.equals("first")) {
                                messagePushDesc.setWxDesc("您好!【" + order.getBuyCompany() + "】的订单已经处理");
                            }
                            if (key.equals("keyword1")) {
                                messagePushDesc.setWxDesc(order.getTradeNo());
                            }
                            if (key.equals("keyword2")) {
                                if (order.getOrderStatu().equals("2")) {
                                    messagePushDesc.setWxDesc("已上报电力交易平台");
                                } else if (order.getOrderStatu().equals("3")) {
                                    messagePushDesc.setWxDesc("交易已完成");
                                }
                            }
                            if (key.equals("remark")) {
                                messagePushDesc.setWxDesc("点击“详情”,查看完整订单信息");
                            }

                            messagePushDesc.setCreateDate(new Date());
                            messagePushDesc.setCreateUser(loginUser);
                            messagePushDesc.setUpdateDate(new Date());
                            messagePushDesc.setUpdateUser(loginUser);
                            messagePushDesc.setDelFlag(false);
                            messagePushDesc.setMessageType(messagePush.getMessageType());
                            electricityMessagePushDescService.insert(messagePushDesc);
                        }
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                LOGGER.error("------->>通知用户失败：openId为null<<-------");
            }
        } else {
            LOGGER.error("------->>通知用户失败：openId为null<<-------");
        }
    }

    /**
     * 封装是否发送成功
     *
     * @param b      boolean
     * @param rs     发送消息的返回值
     * @param string 描述
     * @return 布尔值
     * @author jingjing
     */
    public boolean getBoolean(boolean b, Response<?> rs, String string, int i) {
        b = false;
        if (Response.code.equals(rs.getCode())) {
            if (rs.getData() != null) {
                String code = rs.getCode();
                if (code.equals("200")) {
                    LOGGER.error(string + "------>>发送消息成功为：" + rs.getMsg() + "<<------");
                } else {
                    b = true;
                    if (i == 5) {
                        b = false;
                    }
                    LOGGER.error(string + "XXXXXXXX失败错误信息为：" + rs.getMsg() + "重新发送XXXXXXX");
                }
            } else {
                LOGGER.error("------>>" + string + "失败返回状态码为null<<------");
            }
        } else {
            LOGGER.info("------>>" + string + "发送消息成功<<------");
        }

        return b;
    }
}
